/**
 * 
 */
package cn.agiledata.bank.common.web;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import cn.agiledata.bank.account.service.AccountSummary;
import cn.agiledata.bank.common.util.Constant;
import cn.agiledata.bank.common.util.WebUtil;

/**
 * @author 马贤波
 * 
 * May 17, 2006
 */
public class SessionListener implements HttpSessionListener {

	public void sessionCreated(HttpSessionEvent session) {
	}

	public void sessionDestroyed(HttpSessionEvent session) {
		AccountSummary user = (AccountSummary) session.getSession()
				.getAttribute(Constant.SESSION_ACCOUNT_SUMMARY);
		
		if (user != null) {
			try {
				user.userLogout() ;
				WebUtil.removeApplicationObjectByKey(session.getSession().getServletContext(),user.getAccount().getId(),Constant.APPLICATION_SESSION_ID);
			} catch (Exception e) {
			}
		}
	}

}
